import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { uniqueId } from 'lodash';

interface User {
  key: string;
  name: string;
  age: number;
  address: string;
}

@Component({
  selector: 'app-basic',
  templateUrl: './basic.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BasicComponent implements OnInit {
  data = [];
  constructor() {}

  ngOnInit(): void {
    this.initData();
  }

  initData(): void {
    this.data = Array.from({ length: 5 }).map((item, key) => this.initUser(key));
  }

  initUser(key: number): User {
    return { key: uniqueId('key'), name: `User${key}`, age: 10 + key, address: `Address ${key} Park Road, Sichuan` };
  }
}
